﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _057.Json操作
{
	internal class Program
	{
		static void Main(string[] args)
		{
			// Serialize 反序列化 把字符串转换为对象
			//Skill[] skillArray = JsonConvert.DeserializeObject<Skill[]>(File.ReadAllText("Skills.txt"));
			//foreach (Skill skill in skillArray)
			//{
			//	Console.WriteLine(skill.id + "," + skill.name + "," + skill.damage);
			//}


			// 序列化
			Skill skill = new Skill();
			skill.id = 1;
			skill.name = "Test";
			skill.damage = 100;
			string str = JsonConvert.SerializeObject(skill);
            Console.WriteLine(str);
        }
	}
}
